/**
 * 
 */
package com.noisyair.android.alvin.views;

//import android.R;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Button;

import com.noisyair.android.alvin.R;
import com.noisyair.android.alvin.AccessibilityProperties;
import com.noisyair.android.alvin.Talker;

/**
 * @author darren
 *
 */
public class AlvinButton extends Button {

	/**
	 * @param context
	 */
	public AlvinButton(Context context) {
		super(context);
		makeViewLarge();
	}

	/**
	 * @param context
	 * @param attrs
	 */
	public AlvinButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		makeViewLarge();
	}

	/**
	 * @param context
	 * @param attrs
	 * @param defStyle
	 */
	public AlvinButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		makeViewLarge();
	}

	
	public void makeViewLarge(){
		setTextSize(AccessibilityProperties.BUTTON_TEXT_SIZE);
		//This call doesn't work yet... woulc be grat if it did....
		//setTextAppearance(getContext(), R.style.AlvinButtonText);
		//setTextColor(AccessibilityProperties.TEXT_COLOR_WHITE);
		//setBackgroundColor(AccessibilityProperties.TEXT_COLOR_BLACK);
	}
	
	public void makeViewLargerOnFocus(){
		setTextSize(AccessibilityProperties.SUPER_TEXT_SIZE);
		//setTextColor(AccessibilityProperties.TEXT_COLOR_WHITE);
		//setBackgroundColor(AccessibilityProperties.TEXT_COLOR_BLACK);
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {

		if(event.getAction() == MotionEvent.ACTION_DOWN){			
			if(Talker.shouldTalk()){
				Talker.speak(getText().toString());
			}
			else{
				Log.i("Alvin", "Talker button was not down");
			}
			return true;
		}
		return super.onTouchEvent(event);
	}
}
